-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support 'oxford comma' format and non-string types in listing #690
Conversation
@staticdev The test case for coverage for listing fail before because |
src/human_readable/lists.py
Outdated
from typing import TYPE_CHECKING | ||
|
||
|
||
if TYPE_CHECKING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is much simpler to just remove this if statement and always import this. It is the standard approach.
@@ -38,3 +38,22 @@ def test_listing_with_conjunction( | |||
) -> None: | |||
"""Listing with separator and conjunction.""" | |||
assert lists.listing(*params) == expected | |||
|
|||
|
|||
@pytest.mark.parametrize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also be great to explain this in our examples documentation.
@zwimer I did a review, and I have a suggestion to deal with this in a simpler way. |
Fixes: #693
This PR:
listing
. Depending on location etc., some people list items using an oxford comma. For example:Prints out
The default is
oxford=False
to avoid changing the default behavior.str
inlisting
. The code for this function almost entirely already allowed this, this PR mostly changes type annotations and adds a couple ofstr()
calls to fully support it. This allows for things like:Which may print:
items
. Python defineslist
type as invariant; we should useSequence
instead as that is covariant. That is: